package com.lin.sqltable.generator;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import com.lin.sqltable.entry.BizCase;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.db.Entity;
import cn.hutool.db.SqlRunner;
import cn.hutool.db.ds.DSFactory;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
    	/*try {
			List<Entity> list = Db.use().findAll("biz_case");
			System.err.println(JSONArray.toJSONString(list));
		} catch (SQLException e) {
			e.printStackTrace();
		}*/
    	DataSource ds = DSFactory.get();
    	SqlRunner runner = SqlRunner.create(ds);
    	BizCase bizCase = new BizCase();
    	bizCase.setCaseName("犄角旮旯");
    	bizCase.setCaseFrom(1);
    	bizCase.setCaseNum("11111111111111111111");
    	try {
			runner.insert(Entity.parseWithUnderlineCase(bizCase));
		} catch (SQLException e) {
			e.printStackTrace();
		}
    }
    
    /**
     * 获取表信息
     * @author linfei
     * @param table
     * @return
     */
    public static List<Map<String,String>> getTableInfo(String table){
//    	String table = "biz_case";
//    	List<Map<String,String>>  list = DbInfoUtil.getTableInfo(DbInfoUtil.DRIVER,DbInfoUtil.URL,DbInfoUtil.USER,DbInfoUtil.PWD,table);
		return null;
    }
    public static void saveTable(List<Map<String,String>>  tableDate){
    	if(CollectionUtil.isNotEmpty(tableDate)){
    		for (Map<String, String> map : tableDate) {
    			String COLUMN_NAME = map.get("COLUMN_NAME");
    			String REMARKS = map.get("REMARKS");
			}
    	}
    }
}
